package com.example.dryyzx.dao;

import com.example.dryyzx.entity.Account;
import org.apache.ibatis.jdbc.SQL;

public class AccountSqlProvider {
    public String insertSelective(Account record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("account");
        
        if (record.getAccountNumber() != null) {
            sql.VALUES("account_number", "#{accountNumber,jdbcType=VARCHAR}");
        }
        
        if (record.getPassword() != null) {
            sql.VALUES("password", "#{password,jdbcType=VARCHAR}");
        }
        
        if (record.getType() != null) {
            sql.VALUES("type", "#{type,jdbcType=CHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.VALUES("user_id", "#{userId,jdbcType=INTEGER}");
        }
        
        if (record.getEnable() != null) {
            sql.VALUES("enable", "#{enable,jdbcType=BIT}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Account record) {
        SQL sql = new SQL();
        sql.UPDATE("account");
        
        if (record.getPassword() != null) {
            sql.SET("password = #{password,jdbcType=VARCHAR}");
        }
        
        if (record.getType() != null) {
            sql.SET("type = #{type,jdbcType=CHAR}");
        }
        
        if (record.getUserId() != null) {
            sql.SET("user_id = #{userId,jdbcType=INTEGER}");
        }
        
        if (record.getEnable() != null) {
            sql.SET("enable = #{enable,jdbcType=BIT}");
        }
        
        sql.WHERE("account_number = #{accountNumber,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}